package cfdt.ldl.signatrue.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cfdt.common.vo.ObjectBaseResponse;
import cfdt.ldl.signatrue.service.SignatureService;
import cfdt.ldl.signature.api.request.SignatrueRequest;
import cfdt.ldl.signature.api.response.SignatureResponse;

/**
 * 签名验签-Controller
 *
 * <pre>
 * Modify Information:
 * Author       Date          Description
 * ============ ============= ============================
 * wangxiao      2021年7月29日下午5:34:33      创建Controller类
 *
 * </pre>
 */
@RestController
@RequestMapping("/signature")
public class SignatureController {
    private final Logger logger = LoggerFactory.getLogger(getClass().getName());
    @Autowired
    private SignatureService signatureService;

    // 签名
    @PostMapping("/sign")
    public ObjectBaseResponse sign(@RequestBody SignatrueRequest request){
        logger.info("开始签名");
        return signatureService.sign(request);
    }

    // 验签
    @GetMapping("/verify")
    public ObjectBaseResponse<SignatureResponse> verify(@RequestBody SignatrueRequest request){
        logger.info("开始验签");
        return signatureService.verify(request);

    }
}
